<link rel="stylesheet" href="/opebs/css/bootstrap.min.css">
<link rel="stylesheet" href="/opebs/css/bootstrap-select.css">
<link href="/bs/bootstrap-datetimepicker.min.css" rel="stylesheet">


<script type="text/javascript" src="/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/bs/jquery.form.js"></script>
<script src="/opebs/js/bootstrap.min.js"></script>
<script src="/opebs/js/bootstrap-select.js"></script>
<script src="/bs/moment.js"></script>
<script src="/bs/bootstrap-datetimepicker.min.js"></script>

<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>

<#include "/common/h-ui-base-css.html">
<#--<#include "/common/h-ui-base-js.html">-->
<#include "/common/validation-js.html">

<body>
<article class="page-container">
	<form class="form form-horizontal" id="form-measure-add">
		<div class="row cl">
			<div class="formControls col-xs-3 col-sm-4">
				单号<input type="text" class="input-text" style="background-color:#cef0ce;border:0;"  readonly id="measureId" name="measureId">
			</div>
			<div class="formControls col-xs-3 col-sm-4">
                车牌号
                    <input type="text" class="input-text" value=""  placeholder="" id="carId" name="carId">
			</div>
			<div class="formControls col-xs-3 col-sm-4">
				物料名称
                <select id="materialName" name="materialName" class="selectpicker form-control"  data-live-search="true">
                    <option data-tokens="-1">请选择</option>
                    <#if materials??>
						<#list materials as m>
                             <option data-tokens="${m.value}">${m.name}</option>
						</#list>
					</#if>
                </select>
			</div>
		</div>
		<div class="row cl">
			<div class="formControls col-xs-4 col-sm-4">
				供应商名称
                <select id="supplierName" name="supplierName" class="selectpicker form-control"  data-live-search="true" style="width: 100%;height: 100%">
                    <option data-tokens="">请选择</option>
                    <#if supplier??>
						<#list supplier as m>
                             <option data-tokens="${m.value}">${m.name}</option>
						</#list>
					</#if>
                </select>
			</div>
			<div class="formControls col-xs-4 col-sm-4">
				客户商名称
                <select id="customerName" name="customerName" class="selectpicker form-control"  data-live-search="true">
                    <option data-tokens="">请选择</option>
                    <#if customer??>
						<#list customer as m>
                             <option data-tokens="${m.value}">${m.name}</option>
						</#list>
					</#if>
                </select>
			</div>
			<div class="formControls col-xs-4 col-sm-4">
				移动类型
                <select id="moveType" name="moveType" class="selectpicker form-control"  data-live-search="true">
                    <option data-tokens="-1" >请选择</option>
                    <option data-tokens="IN" value="IN">采购进厂</option>
                    <option data-tokens="OUT" value="OUT">销售出厂</option>
                </select>
			</div>
		</div>
		<div class="row c1">
			<div class="formControls col-xs-4 col-sm-4">
				毛重<input type="text" class="input-text" value="" placeholder="" id="grossWeight" name="grossWeight">
			</div>
			<div class="formControls col-xs-4 col-sm-4">
				毛重时间
                <div class='input-group date' id='grossWeightDate'>
                    <input type='text'  name="grossWeightDate"  class="form-control" />
                    <span class="input-group-addon">
                   	 <span class="glyphicon glyphicon-calendar"></span>
                	</span>
                </div>
			</div>
			<div class="formControls col-xs-4 col-sm-4">
				毛重计量员<input type="text" class="input-text" value="" placeholder="" id="grossWeightP" name="grossWeightP">
			</div>
		</div>
		<div class="row c1">
			<div class="formControls col-xs-4 col-sm-4">
				皮重<input type="text" class="input-text" value="" placeholder="" id="tare" name="tare" >
			</div>
			<div class="formControls col-xs-4 col-sm-4">
				皮重时间
                <div class='input-group date'  id='tareDate'>
                    <input type='text' name="tareDate" class="form-control" />
                    <span class="input-group-addon">
                   	 <span class="glyphicon glyphicon-calendar"></span>
                	</span>
                </div>
			</div>
			<div class="formControls col-xs-4 col-sm-4">
				皮重计量员<input type="text" class="input-text" value="" placeholder="" id="tareP" name="tareP">
			</div>
		</div>
		<div class="row cl">
			<div class="formControls col-xs-4 col-sm-4">
				卸货标志
                <select id="unloadSymbol" name="unloadSymbol" class="selectpicker form-control"  data-live-search="true">
                    <option data-tokens="-1">请选择</option>
                    <option data-tokens="0" value="0">未卸货</option>
                    <option data-tokens="1" value="1">已卸货</option>
                </select>
			</div>
			<div class="formControls col-xs-4 col-sm-4">
				退货标志
                <select id="returnSymbol" name="returnSymbol" class="selectpicker form-control"  data-live-search="true">
                    <option data-tokens="-1">请选择</option>
                    <option data-tokens="0" value="0">未退货</option>
                    <option data-tokens="1" value="1">已退货</option>
                </select>
			</div>
			<div class="formControls col-xs-4 col-sm-4">
				退货原因<input type="text" class="input-text" value="" placeholder="" id="returnYY" name="returnYY">
			</div>
		</div>
		<div class="row cl">
			<div class="formControls col-xs-4 col-sm-4">
				净重<input type="text" class="input-text" readonly  style="background-color:#cef0ce;border:0;"  id="suttle" name="suttle">
			</div>
			<div class="formControls col-xs-4 col-sm-4">
				产生净重时间<input type="text" class="input-text" readonly  style="background-color:#cef0ce;border:0;"  id="suttleDate" name="suttleDate">
			</div>
            <div class="formControls col-xs-4 col-sm-4">
                计量关闭标志
                <select id="closeSymbol" name="closeSymbol" class="selectpicker form-control"  data-live-search="true">
                    <option data-tokens="-1">请选择</option>
                    <option data-tokens="0" value="0">未计量完</option>
                    <option data-tokens="1" value="1">计量完毕</option>
                </select>
            </div>
		</div>
		<div class="row cl">

			<div class="formControls col-xs-4 col-sm-4">
				车辆最大载重量<input type="text" class="input-text"  id="max" name="max">
			</div>
		</div>

		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>
<!--请在下方写此页面业务相关的脚本-->

<script type="text/javascript">


	$(function(){

        $('#measureId').val(getMeasureId());

        $('#grossWeightDate').datetimepicker({
            format: 'YYYY-MM-DD hh:mm:ss',
            locale: moment.locale('zh-cn')
        });
        $('#tareDate').datetimepicker({
            format: 'YYYY-MM-DD hh:mm:ss',
            locale: moment.locale('zh-cn')
        });

		$("#form-measure-add").validate({
			rules:{

                carId:{
                    required:true
				},
                grossWeight:{
					required:true,
                    number:true

				},
                max:{
                    required:true,
                    number:true
				},
                tare:{
					required:true,
                    number:true

				},
                supplierName:{
                    required:true
				}
			},
			onkeyup:false,
			focusCleanup:true,
			success:"valid",
			submitHandler:function(form){

                var materialName = $('#materialName').val();
                if(materialName=='请选择'){
                    layer.msg("请选择物料");
                    return false;
                }
                var supplierName = $('#supplierName').val();
                if(supplierName=='请选择'){
                    layer.msg("请选择供应商");
                    return false;
				}

                var customerName = $('#customerName').val();
				if(customerName=='请选择'){
				    layer.msg("请选择客户商");
				    return false;
				}

                var moveType = $('#moveType').val();
				if(moveType=='请选择'){
                    layer.msg("请选择移动类型");
                    return false;
				}
                var unloadSymbol = $('#unloadSymbol').val();
                if(unloadSymbol=='请选择'){
                    layer.msg("请选择卸货标记");
                    return false;
                }
                var returnSymbol = $('#returnSymbol').val();
                if(returnSymbol=='请选择'){
                    layer.msg("请选择退货标记");
                    return false;
                }
                var closeSymbol = $('#closeSymbol').val();
                if(closeSymbol=='请选择'){
                    layer.msg("请选择关闭标记");
                    return false;
                }
                var tare = $('#tare').val();
                var gross = $('#grossWeight').val();
                var max = $('#max').val();
                if(parseFloat(tare)>parseFloat(max)||parseFloat(gross)>parseFloat(max)){
                    layer.msg("请核对最大载重量");
                    return false;
				}
				$(form).ajaxSubmit({
					type: 'post',
					url: "/measure-ins-upd-del/-1" ,
					data :$("form-measure-add").serialize(),
					async:false,
					success: function(data){
						layer.msg('添加成功!',{icon:1,time:1000});
					},
					error: function(XmlHttpRequest, textStatus, errorThrown){
						layer.msg('error!',{icon:1,time:1000});
					}
				});
				var index = parent.layer.getFrameIndex(window.name);
				var handler = '/measure-list/1/20';
				parent.$('#measure_table').datagrid('options').url = handler;
				parent.$('#measure_table').datagrid('reload');
				parent.layer.close(index);
			}
		});


	});

</script>


<script type="text/javascript">
    function getMeasureId(){
        var myDate = new Date();
        var year=myDate.getFullYear();
        var month=myDate.getMonth()+1;
        var date=myDate.getDate();
        var h=myDate.getHours();       //获取当前小时数(0-23)
        var m=myDate.getMinutes();     //获取当前分钟数(0-59)
        var s=myDate.getSeconds();
        var now=year+getNow(month)+getNow(date)+getNow(h)+getNow(m)+getNow(s);
        return now;
    }
    function getNow(s) {
        return s < 10 ? '0' + s: s;
    }

</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
